package com.demo.mircoauth.service.impl;

import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.demo.mircoauth.entity.SysClient;
import com.demo.mircoauth.service.SysClientService;
import com.demo.mircoauth.mapper.SysClientMapper;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.ClientRegistrationException;
import org.springframework.stereotype.Service;

import javax.management.Query;

/**
 *
 */
@Service
public class SysClientServiceImpl extends ServiceImpl<SysClientMapper, SysClient> implements SysClientService, ClientDetailsService {

    @Override
    public ClientDetails loadClientByClientId(String s) throws ClientRegistrationException {
        QueryWrapper<SysClient> clientQuery = new QueryWrapper<SysClient>().eq("client_id", s);
        SysClient sysClient = baseMapper.selectOne(clientQuery);
        Assert.notNull(sysClient,"客户端凭证不正确");
        return sysClient;
    }
}





